<?php
/**
 * Created by PhpStorm.
 * User: iamya
 * Date: 2017/11/27
 * Time: 8:41
 */

namespace app\common;


use think\Model;

class LeadsModel extends Model
{
    protected $name = 'leads'; //定义用户表
    //开启自动写入时间戳
    protected $autoWriteTimestamp = true;
    // 定义自动完成的属性
    protected $auto = []; //新增修改
    protected $insert = []; //插入
    protected $update = []; //修改
    protected $readonly = ['creator_userid'];

    public function record()
    {
        return $this->hasMany('LeadsRecordModel','leads_id ','leads_id ');
    }

    /**
     * 线索转化
     * @param int $leadsId 转化的线索id
     * @param int $customerId 转化后的客户id
     * @param int $businessId 转化后的商机id
     * @return bool 是否转化成功
     */
    public function transformed($leadsId,$customerId,$businessId)
    {
        if ($this->leadsModel->data(['leads_id'=>$leadsId,'customer_id'=>$customerId,'business_id'=>$businessId])){
            return true;
        }else{
            return false;
        }
    }
}